var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "fs"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const fs_1 = __importDefault(require("fs"));
    async function rename(filePath, newFilePath) {
        return new Promise((resolve, reject) => {
            if (fs_1.default.existsSync(newFilePath)) {
                resolve(['文件已存在', false]);
            }
            else {
                fs_1.default.promises.rename(filePath, newFilePath).then(() => {
                    resolve([null, true]);
                }).catch((err) => {
                    resolve([err, false]);
                });
            }
        });
    }
    exports.default = rename;
});
